<?php
class mupload extends CI_Model {

	function Mgis(){
		parent::__construct();
	}


	function newEload($data) {
		$this->db->insert('t_mtr_mfino', $data);
	}

	function editEload($data) {
		$this->db->where('eload_number', $data['eload_number']);
		$this->db->update('t_mtr_mfino', $data);
	}

	function getEload($data) {
		$this->db->get_where('t_mtr_mfino', array('eload_number' => $data) );
		return $this->db->count_all_results();
	}
    
    function getTerritory($parent_id){
        $this->db->select('territory_id, territory_name');
        $this->db->where ('parent_id',$parent_id);
        $res=$this->db->get('t_mtr_territory');
        $i=0;
        foreach($res->result_array() as $k=>$v ){
           
            $result[$v['territory_id']]=$v['territory_name'];
            $i++;
        }
        return $result;
    }

	function mFinoList() {

		$sIndexColumn = "mfino_id"; //index column untuk kecepatan akses data
		$sTable = "t_mtr_mfino"; //table pertama
		$defaultOrder = "1"; //default order berdasarkan field yg ada pada $aColumns
		$userlogin = $this->session->userdata('username'); //user credentials
		$aColumns = array("mfino_id", "eload_number","regional"); //field2 yg akan ditampilkan pada dataTables
		$flag = "";

		$inputQuery =  "
		SELECT ".str_replace(" , ", " ", implode(", ", $aColumns))."
		FROM   $sTable";

		return $this->serversidedatatables->executeServerSideProcess($defaultOrder, $flag, $userlogin, $inputQuery, $aColumns, $sIndexColumn);

		// $this->db->select('mfino_id, regional, eload_number');
		// $query = $this->db->get('t_mtr_mfino');
		// return $query->result();
	}
    
    function saveMobileUpload($data)
    {
        $this->db->insert('t_mtr_update_mobile_app',$data());
        echo 'sukses';
        
    }
}